package com.capgemini.remind.pojo;

import com.capgemini.remind.constant.CONST;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by annson on 2016/7/3.
 */
public class CustomerPromotion implements Serializable {
    private Long id;
    private String dealerId;
    private String maintenanceType;
    private String promotionalContent;
    private Long periodOfValidity;
    private String timeUnit;

    private String attr1;
    private String attr2;
    private String attr3;

    private String createBy;
    private Date createDate;
    private String lastUpdateBy;
    private Date lastUpdateDate;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDealerId() {
        return dealerId;
    }

    public void setDealerId(String dealerId) {
        this.dealerId = dealerId;
    }

    public String getMaintenanceType() {
        return maintenanceType;
    }

    public void setMaintenanceType(String maintenanceType) {
        this.maintenanceType = maintenanceType;
    }

    public String getPromotionalContent() {
        if("0".equals(attr1)){
            promotionalContent = "买" + attr2 + "赠送" + attr3;
        }else if("1".equals(attr1)){
            promotionalContent = "买" + attr2 + "减" + attr3;
        }else if("2".equals(attr1)){
            promotionalContent = "送" + attr2 ;
        }else if("3".equals(attr1)){
            promotionalContent = "送" + attr2 ;
        }else if("4".equals(attr1)){
            promotionalContent = attr2 ;
        }
        return promotionalContent;
    }

    public void setPromotionalContent(String promotionalContent) {
        this.promotionalContent = promotionalContent;
    }

    public Long getPeriodOfValidity() {
        return periodOfValidity;
    }

    public void setPeriodOfValidity(Long periodOfValidity) {
        this.periodOfValidity = periodOfValidity;
    }

    public String getTimeUnit() {
        return timeUnit;
    }

    public void setTimeUnit(String timeUnit) {
        this.timeUnit = timeUnit;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getLastUpdateBy() {
        return lastUpdateBy;
    }

    public void setLastUpdateBy(String lastUpdateBy) {
        this.lastUpdateBy = lastUpdateBy;
    }

    public Date getLastUpdateDate() {
        return lastUpdateDate;
    }

    public void setLastUpdateDate(Date lastUpdateDate) {
        this.lastUpdateDate = lastUpdateDate;
    }

    public String getSmsText(){
        StringBuilder text = new StringBuilder();

        text.append(getPromotionalContent());
        if(periodOfValidity != null && StringUtils.isNotBlank(timeUnit)){
            text.append("[收到短信后的").append(periodOfValidity).append(CONST.getTimeUnit(timeUnit)).append("内有效],");
        }

        return text.toString();
    }

    public String getAttr1() {
        return attr1;
    }

    public void setAttr1(String attr1) {
        this.attr1 = attr1;
    }

    public String getAttr2() {
        return attr2;
    }

    public void setAttr2(String attr2) {
        this.attr2 = attr2;
    }

    public String getAttr3() {
        return attr3;
    }

    public void setAttr3(String attr3) {
        this.attr3 = attr3;
    }
}
